<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 了解 -->
    <div id="app">
      <h2>透传attrs</h2>
      <child name="麦克" age="20" sex="1"></child>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        props: ["name", "age"],
        template: `
          <div>child组件 - {{ name }} - {{ age }}</div>
        `,
        mounted() {
          // 获取到父组件传的自定义属性，(没有被子组件的props接收)
          console.log(this.$attrs);
          console.log(this.$attrs.sex);
        },
      };

      createApp({
        data() {
          return {};
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
